<template>
    <div>
        <div>
            <el-input class="searchInput" 
                    clearable
					@clear="keywordClear"
                    v-model="keyword"
                    placeholder="请输入学院关键字进行搜索..."
                    @keydown.enter.native="doSearch"
                    prefix-icon="el-icon-search">
            </el-input>
            <el-button icon="el-icon-search" type="primary" @click="doSearch">搜索</el-button> 
        </div>
        <div class="baseMain">
            <el-table
                    :data="audits"
                    border
                    stripe
                    style="width:79%">
				<el-table-column
					prop="departmentName" label="学院" width="180">
				</el-table-column>	
                <el-table-column
                    prop="baseName" label="公司名字" width="260">
                </el-table-column>
                <el-table-column
                    prop="city" label="所在城市" width="80">
                </el-table-column>
				<el-table-column
				    prop="createTime" label="申报时间" width="160">
				</el-table-column>
				<el-table-column
				    prop="updateTime" label="审核时间" width="160">
				</el-table-column>
				<el-table-column
				    label="申报信息" width="100">
					<template slot-scope="scope">
						<el-button type="infor" @click="showInfoView(scope.row)" >查看</el-button>
					</template>
				</el-table-column>
                <el-table-column
                    prop="status" label="审核状态">
					<template slot-scope="scope">
						<el-tag  type="Fail" v-if="scope.row.status == 2">未通过</el-tag>
					</template>
                </el-table-column>
            </el-table>
        </div>
		<div class="pageSelect">
			<el-pagination
				  @current-change="handleCurrentChange"
				  :current-page="current"
				  :page-size="size"
				  layout="total, prev, pager, next"
				  :total="total">
			</el-pagination>
		</div>
		<el-dialog :title="title" :visible.sync="dialogVisible" width="35%">
			<el-form ref="declareForm" :model="declareInfo" label-position="left" label-width="95px">
				<el-form-item label="学院">
					<el-input v-model="declareInfo.departmentName" style="width: 280px;"></el-input>
				</el-form-item>
				<el-form-item label="公司名">
					<el-input size="small" v-model="declareInfo.baseName" placeholder="请输入公司名" style="width: 280px;"></el-input>
				</el-form-item>
				<el-form-item label="所在城市">
					<el-input size="small" v-model="declareInfo.city" placeholder="请输入公司所在城市" style="width: 180px;"></el-input>
				</el-form-item>
				<el-form-item label="详细地址">
					<el-input v-model="declareInfo.address" type="textarea" style="width: 350px;" 
					placeholder="请输入公司详细地址" :autosize="{ minRows: 2, maxRows: 4}"></el-input>
				</el-form-item>
				<el-form-item label="可实习岗位" >
					<el-input v-model="declareInfo.position" type="textarea" autosize placeholder="请输入可提供的实习岗位(中间用;隔开)" style="width: 350px;"></el-input>
				</el-form-item>
				<el-form-item label="公司简介" >
					<el-input v-model="declareInfo.introduction" type="textarea" style="width: 350px;" placeholder="请输入该公司的简介"
					:autosize="{ minRows: 6, maxRows: 10}" maxlength="100" show-word-limit></el-input>
				</el-form-item>
			</el-form>
		</el-dialog>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                audits:[],
                keyword:'',
				current: 1,
				size: 10,
				total: 0,
				status: 2,
				title: '',
				dialogVisible: false,
				declareInfo: {},
                
            }
        },
		mounted() {
			this.initDeclaresFail();
		},
        methods: {
			initDeclaresFail(){
				let url = '/base/audit/?current=' + this.current + '&size=' + this.size + '&status=' + this.status + '&keyword=' + this.keyword;
				this.getRequest(url).then(resp =>{
					if(resp){
						this.audits = resp.data;
						this.total = resp.total;
					}
				})
			},
			keywordClear(){
				this.current = 1;
				this.initDeclaresFail();
			},
            doSearch(){
				this.current = 1;
                this.initDeclaresFail();
            },
			showInfoView(data){
				this.title = '查看详细信息';
				this.declareInfo = data;
				this.dialogVisible = true;
			},
			handleCurrentChange(currentPage){
				this.current = currentPage;
				this.initDeclaresFail();
			}
        }
    }
</script>

<style scoped>
    .searchInput{
        width: 300px;
        margin-right: 8px;
    }
    .baseMain{
        margin-top: 10px;
    }
	.pageSelect{
		width: 79%;
		margin-top: 5px;
		display: flex;
		justify-content: flex-end;
	}
</style>